package com.weiyuanstudio.nextstep.configuration;

import com.weiyuanstudio.nextstep.thirdparty.api.UserAgentInterceptors;
import okhttp3.OkHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 项目配置
 */
@Configuration
public class ProjectConfiguration {

    /**
     * OkHttpClient单例
     * @return OkHttpClient
     */
    @Bean
    OkHttpClient getOkHttpClient() {
        return new OkHttpClient.Builder()
                .addNetworkInterceptor(new UserAgentInterceptors("weiyuanstudio/NextStep"))
                .build();
    }

    @Bean
    public boolean isDebugMode() {
        String debugMode = System.getenv("DEBUG");
        return Boolean.parseBoolean(debugMode);
    }
}
